package com.bluezone.dec.system.controller;

import com.bluezone.dec.common.CacheConstant;
import com.bluezone.dec.common.JsonResult;
import com.bluezone.dec.common.SystemConstant;
import com.bluezone.dec.system.service.EnterpriseSecurityStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * @Description 企业安全情况统计controller
 * @Author  HHL
 * @CreateDate 2018/11/6 11:36
 * @Company 浙江航天恒嘉数据科技有限公司
 */
@Api(tags = "企业安全情况统计")
@RestController
@RequestMapping("/dec/security")
public class EnterpriseSecurityStatisticsController {

    @Autowired
    private EnterpriseSecurityStatisticsService enterpriseSecurityStatisticsService;

    @ApiOperation("获取标题卡片数据")
    @GetMapping("/title")
    public JsonResult getCardData() {
        return new JsonResult().ok(enterpriseSecurityStatisticsService.getCardData());
    }


    @ApiOperation("获取环形图的数据")
    @GetMapping("/ring")
    public JsonResult getRingData() {
        List<Map<String, Object>> ringData = new ArrayList<>();
        ringData.add(enterpriseSecurityStatisticsService.getEnterpriseLevel(SystemConstant.STANDARDIZATION, "企业标准化等级",CacheConstant.STANDARDIZATION));
        ringData.add(enterpriseSecurityStatisticsService.getEnterpriseLevel(SystemConstant.SCALE, "企业规模等级",CacheConstant.SCALE));
        ringData.add(enterpriseSecurityStatisticsService.getEnterpriseLevel(SystemConstant.REGULATORY_LEVEL,"企业监管层级",CacheConstant.REGULATORY_LEVEL));
        return new JsonResult().ok(ringData);
    }


    @ApiOperation("获取危险化学品企业分布的数据")
    @GetMapping("/danger")
    public JsonResult getDangerData() {
        return new JsonResult().ok(enterpriseSecurityStatisticsService.getDangerData());
    }


    @ApiOperation("获取报警月份统计的数据")
    @GetMapping("/alarm")
    public JsonResult getAlarmStatisticsData() {
        return new JsonResult().ok(enterpriseSecurityStatisticsService.alarmRecord());
    }

    @ApiOperation("获取报警设备类型统计的数据")
    @GetMapping("/device")
    public JsonResult getAlarmDeviceData() {
        return new JsonResult().ok(enterpriseSecurityStatisticsService.typeStatistics(SystemConstant.DEVICE_TYPE, SystemConstant.ALERT_TYPE,CacheConstant.DEVICE_TYPE));
    }


    @ApiOperation("获取报警行业统计数据")
    @GetMapping("/industry")
    public JsonResult getAlarmIndustryData() {
        return new JsonResult().ok(enterpriseSecurityStatisticsService.industryStatistics());
    }

    @ApiOperation("预警级别分类统计")
    @GetMapping("/level")
    public JsonResult getAlertType() {
        return new JsonResult().ok(enterpriseSecurityStatisticsService.typeStatistics(SystemConstant.ALARM_PARAM, SystemConstant.ALARM_LEVEL,CacheConstant.ALARM_PARAM));
    }

}
